//****************************************************************
//* Copyright (c) 2004 Ford Motor Company. All Rights Reserved.
//*
//* $$Workfile:   FindUsrQuery.java  $$
//* $$Revision:   1.3  $$
//* $$Author:   aponte  $$
//* $$Date:   Dec 15 2008 07:08:28  $$
//*
//*****************************************************************
package ar.com.ford.it.fullEconomics.persistence.dao.query;

import oracle.toplink.expressions.Expression;
import oracle.toplink.expressions.ExpressionBuilder;
import ar.com.ford.it.fullEconomics.persistence.dto.Tms0008UsrprofVw;
import com.ford.it.persistence.impl.toplink.CustomExpressionFactory;

public class FindUsrQuery implements CustomExpressionFactory {

    
    public Expression createExpression(ExpressionBuilder builder,
                                       Object[] parameters) {
        Expression exp = null;
        Tms0008UsrprofVw tms0008UsrprofVw = (Tms0008UsrprofVw) parameters[0];
        String cdsId = null;
        String systemCode = null;
        
        cdsId = tms0008UsrprofVw.getMs0008UserCodeC();
        systemCode = tms0008UsrprofVw.getMs0008SystemCodeC();

        if (cdsId != null) {
            exp = builder.get("ms0008UserCodeC").equal(cdsId);
        }
        
        if (systemCode != null) {
            if (exp != null)
                exp = exp.and(builder.get("ms0008SystemCodeC").equal(systemCode));
            else
                exp = builder.get("ms0008SystemCodeC").equal(systemCode);
        }
        return exp;
    }

}
